# $Id: Makefile 69 2004-11-18 10:18:04Z jonas $
EXECUTABLE = eos
VERSION = 1.0.0

# CC is for the name of the C compiler. CPPFLAGS denotes pre-processor
# flags, such as -I options. CFLAGS denotes flags for the C compiler.
# CXXFLAGS denotes flags for the C++ compiler.
# Add -O2 at CFLAGS when making the final one... and remove -ggdb3...

LINKCC = $(CXX)
CPPFLAGS = -DVERSION=\"$(VERSION)\"
LDFLAGS =
CC = gcc
#CFLAGS = -Wall -ggdb3
CFLAGS = -Wall -pipe -O3 -fforce-addr -falign-functions=4 -maccumulate-outgoing-args -fomit-frame-pointer
CXX = g++
CXXFLAGS = $(CFLAGS)

SRCS := $(wildcard *.c) $(wildcard *.cpp)
OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) \
        $(patsubst %.cpp,%.o,$(wildcard *.cpp))
DEPS := $(patsubst %.o,%.d,$(OBJS))

# "all" is the default target. Simply make it point to myprogram.

all: $(EXECUTABLE)

# Define the components of the program, and how to link them together.
# These components are defined as dependencies; that is, they must be
# made up-to-date before the code is linked.

$(EXECUTABLE): $(DEPS) $(OBJS)
	$(LINKCC) $(LDFLAGS) -o $(EXECUTABLE) $(OBJS)

# Specify that the dependency files depend on the C source files.

%.d: %.c
	$(CC) -M $(CPPFLAGS) $< > $@
	$(CC) -M $(CPPFLAGS) $< | sed s/\\.o/.d/ >> $@

%.d: %.cpp
	$(CXX) -M $(CPPFLAGS) $< > $@
	$(CXX) -M $(CPPFLAGS) $< | sed s/\\.o/.d/ >> $@

# Specify that all .o files depend on .c files, and indicate how
# the .c files are converted (compiled) to the .o files.

clean:
	-rm -f $(OBJS) $(EXECUTABLE) $(DEPS) *~

explain:
	@echo "The following information represents your program:"
	@echo "Final executable name: $(EXECUTABLE)"
	@echo "Source files:     $(SRCS)"
	@echo "Object files:     $(OBJS)"
	@echo "Dependency files:   $(DEPS)"

depend: $(DEPS)
	@echo "Dependencies are now up-to-date."

-include $(DEPS)

